home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 276-300 / 299 / rxil / src / lock.c < prev    next >
C/C++ Source or Header  |  1995-03-14  |  3KB  |  125 lines

  1. /* lock.c */
  2.  
  3. /*        Copyright © 1989 by Donald T. Meyer, Stormgate Software
  4.  *        All Rights Reserved
  5.  */
  6.  
  7.  
  8.  
  9. #include "rxil.h"
  10.  
  11.  
  12.  
  13. /* NAME
  14.  *        RxilCmdLock
  15.  *
  16.  * SYNOPSIS
  17.  *        RxilCmdLock( rexxmsg );
  18.  *
  19.  *        struct RexxMsg *rexxmsg;
  20.  *
  21.  * FUNCTION
  22.  *        This is a "command" which would be called from the dispatch
  23.  *        function.  This would handle the "LOCK" command that an ARexx
  24.  *        program could send to the application requesting access to
  25.  *        the private port.
  26.  *
  27.  * INPUTS
  28.  *        rexxmsg        A pointer to a RexxMsg structure.
  29.  *
  30.  * RESULT
  31.  *        None
  32.  *
  33.  * SIDES
  34.  *
  35.  * HISTORY
  36.  *        01-Aug-89    Creation.
  37.  *
  38.  * BUGS
  39.  *
  40.  * SEE ALSO
  41.  *        RxilCmdUnlock()
  42.  */
  43.  
  44. void RxilCmdLock( struct RexxMsg *rexxmsg )
  45. {
  46.     /* Check for wether or not the program which issued this command is
  47.      * set to receive a result string (options results).
  48.      * Normally this would be handled downstream by  RxilCheckResult()
  49.      * but in this case we need to know wether or not to set the
  50.      * locked flag.  Why do we need to know this?  Because we don't
  51.      * want to lock if the external program won't be able to receive
  52.      * our adrress (and therefore never UNlock us!).
  53.      */
  54.     if(  FlagIsClear( rexxmsg->rm_Action, RXFF_RESULT )  )
  55.     {
  56.         rexxmsg->rm_Result1 = RXERR_REQUIRES_RESULT_FLAG;
  57.         return;
  58.     }
  59.  
  60.  
  61.     if( global_rdef->LockCount != 0 )
  62.     {
  63.         /* We are already locked.  Return a failure code. */
  64.         rexxmsg->rm_Result1 = RXERR_ALREADY_LOCKED;
  65.     }
  66.     else
  67.     {
  68.         RxilSetResult( rexxmsg, global_rdef->SecretPortName );
  69.         ++global_rdef->LockCount;
  70.     }
  71. }
  72.  
  73.  
  74.  
  75. /* NAME
  76.  *        RxilCmdUnlock
  77.  *
  78.  * SYNOPSIS
  79.  *        RxilCmdUnlock( rexxmsg );
  80.  *
  81.  *        struct RexxMsg *rexxmsg;
  82.  *
  83.  * FUNCTION
  84.  *        This is a "command" which would be called from the dispatch
  85.  *        function.  This would handle the "UNLOCK" command that an
  86.  *        ARexx program could send to the application requesting
  87.  *        access to the private port.
  88.  *
  89.  *         Note: The privilege level for this command should be "secret",
  90.  *         since anyone who locked us will be able to meet that level,
  91.  *         and those who have not locked us can't slip the lock out
  92.  *         from under those who did (so to speak).
  93.  *
  94.  * INPUTS
  95.  *        rexxmsg        A pointer to a RexxMsg structure.
  96.  *
  97.  * RESULT
  98.  *        None
  99.  *
  100.  * SIDES
  101.  *
  102.  * HISTORY
  103.  *        01-Aug-89    Creation.
  104.  *
  105.  * BUGS
  106.  *
  107.  * SEE ALSO
  108.  *        RxilCmdLock()
  109.  */
  110.  
  111. void RxilCmdUnlock( struct RexxMsg *rexxmsg )
  112. {
  113.     if( global_rdef->LockCount != 0 )
  114.     {
  115.         /* We are already locked.  This is a valid command. */
  116.         --global_rdef->LockCount;
  117.     }
  118.     else
  119.     {
  120.         /* We are not locked.  Tell caller about their error. */
  121.         rexxmsg->rm_Result1 = RXERR_NOTHING_TO_UNLOCK;
  122.     }
  123. }
  124.  
  125.